/**
 * 项目名称:多重catch块
 *
 * @Author: 夏国倩
 * @Date: 2023/9/15 10:20
 * @Copyright
 */
package Exception;
import java.util.InputMismatchException;
import java.util.Scanner;
public class Exception3 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入被除数：");
        try {
            int num1= sc.nextInt();
            System.out.println("请输入除数：");
            int num2= sc.nextInt();
            System.out.println(num1+"/"+num2+"="+num1/num2);
            //return;//finally语句块仍旧会执行
        }catch (InputMismatchException e){
            System.out.println("被除数和除数必须是整数");
        }catch(ArithmeticException e){
            System.out.println("除数不能为0");
        }catch (Exception e){ //Exception放在其他异常之前，会报错
            System.out.println("其他未知异常");
        }finally {
            System.out.println("感谢使用本程序");
        }
    }
}
